package Features.RatFeild
{
	import com.greensock.TimelineLite;
	import com.greensock.TweenLite;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextFormatAlign;
	
	import org.SFramework.Architechture.SViewNode;
	import org.SuiComponents.SuiImage;
	import org.SuiComponents.SuiSimpleButton;
	
	public class DlgSummary extends SViewNode
	{
		private var imgBg:SuiImage;
		private var btnPostScore:SuiSimpleButton;
		
		public function DlgSummary()
		{
			
		}
		
		override public function onInit(initData:Object):Boolean
		{
			initData	=	[50, 64, 92, 20, 15, 13, 50];
			
			imgBg				=	new SuiImage();
			imgBg.setSWFSource( Assets.assetsSwfName, "dlgSummary" );
			addChild( imgBg );
			
			btnPostScore							=	new SuiSimpleButton( "" );
			btnPostScore.setSize( 176, 30 );
			btnPostScore.addEventListener( MouseEvent.CLICK, handleBtnPostScore );
			btnPostScore.x							=	130;
			btnPostScore.y							=	280;
			btnPostScore.title.text					=	"Save My Score";
			btnPostScore.title.fontName				=	"WoodLook";
			btnPostScore.title.embedFont			=	true;
			btnPostScore.title.textSize				=	15;
			btnPostScore.title.enabled				=	true;
			btnPostScore.title.textColor			=	0xffffff;
			btnPostScore.title.textVerticalAlign	=	"center";
			btnPostScore.title.textAlign			=	TextFormatAlign.CENTER;
			btnPostScore.setSWFSource( Assets.assetsSwfName, "btnPostScore" );
			addChild( btnPostScore );
			
			return true;
		}
		
		override public function onShow(initData:Object):void
		{
			x	=	-300;	
			y	=	-300;
			
			scaleX	=	0.1;
			scaleY	=	0.1;
			
			var tl:TimelineLite	=	new TimelineLite();
			tl.append( TweenLite.to( this, 0.2, {scaleX:1.15, scaleY:1.2, x:75, y:75} ) );
			tl.append( TweenLite.to( this, 0.1, {scaleX:0.85, scaleY:0.8, x:63, y:63} ) );
			tl.append( TweenLite.to( this, 0.05, {scaleX:1.0, scaleY:1.0, x:68, y:68} ) );
			
			tl.play();
		}
		
		override public function onHide(onHideComplete:Function):void
		{			
			super.onHide( onHideComplete );
		}
				
		private function handleBtnPostScore( e:Event ):void
		{
			Global.viewsCabinet.hideLayer( ShareMacros.MV_DlgSummary );
			
			Application.goMainMenu();
		}
	}
}